﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Activities;

using CloudSoft.Workflows;

namespace ERPStore.Exporter.Workflows.Activities
{
	public sealed class ProductExceptionLogger : CodeActivity
	{
		public InArgument<Exception> ExceptionArgument { get; set; }
		public InArgument<ERPStore.Models.Product> ProductArgument { get; set; }

		protected override void Execute(CodeActivityContext context)
		{
			var ex = context.GetValue(this.ExceptionArgument);
			var product = context.GetValue(this.ProductArgument);
			var logger = context.GetService<ERPStore.Logging.ILogger>();
			ex.Data.Add("ProductId", product.Id);
			ex.Data.Add("ProductCode", product.Code);
			logger.Error(ex);

		}
	}
}
